#include<iostream>
#include<string>
using namespace std;

int main()
{
    string str;
    getline(cin, str);
    int pos = 0;
    while (pos < str.size())
    {
        if (str[pos] != '6')
        {
            cout << str[pos++];
        }
        else
        {
            string tmp;
            while (pos < str.size() && str[pos] == '6')
            {
                tmp += str[pos++];
            }
            // cout << tmp.size() << endl;
            if (tmp.size() > 3 && tmp.size() <= 9) cout << '9';
            else if (tmp.size() > 9) cout << "27";
            else cout << tmp;
        }
    }
    return 0;
}